package com.example.converter.config;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.lang.annotation.Annotation;

/**
 * formData 请求枚举转换
 * @author wangwc@wumart.com
 * @version v1.0.0
 * @date 2021-11-29 18:16
 */
@Slf4j
//@Component
public class ConverterFactoryConfig {

    @Autowired
    private FormattingConversionService formattingConversionService;
    @Setter
    private Class<? extends Annotation> httpCode;
    @Setter
    private Class<? extends Annotation> httpName;

    /**
     * 等效与 WebMvcConfigurationSupport.addFormatters 方法
     */
    @PostConstruct
    public void addFormatters() {
//        formattingConversionService.addConverterFactory(new EnumsConvertorFactory());
//        formattingConversionService.addConverterFactory(new StringToEnumConverterFactory());
        log.info("加载StringToEnumConverterFactory");
    }

}
